﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class shopcarTest_Default : System.Web.UI.Page
{
    string cookie = "ShopCarTest";
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        TestP1 p = new TestP1();
        p.PK = this.TextBox1.Text;
        p.Name = this.TextBox2.Text;
        p.Price =float.Parse(this.TextBox3.Text);

        ShopCar<TestP1> car = ShopCar<TestP1>.LoadFromCookie(cookie+"1");
        car.Add(p, int.Parse(this.TextBox4.Text));        
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        TestP2 p = new TestP2();
        p.ID = this.TextBox5.Text;
        p.Name = this.TextBox6.Text;
        p.JG = float.Parse(this.TextBox7.Text);

        ShopCar<TestP2> car = ShopCar<TestP2>.LoadFromCookie(cookie+"2");
        car.Add(p, int.Parse(this.TextBox8.Text));      
    }
    protected void Button3_Click(object sender, EventArgs e)
    {
        Response.Redirect("shopcar.aspx");
    }
    protected void Button4_Click(object sender, EventArgs e)
    {
        ShopCar<TestP1> car = ShopCar<TestP1>.LoadFromCookie(cookie + "1");
        car.Remove(this.TextBox1.Text);
    }
    protected void Button5_Click(object sender, EventArgs e)
    {
        ShopCar<TestP1> car = ShopCar<TestP1>.LoadFromCookie(cookie + "1");
        car.SetCount(this.TextBox1.Text, int.Parse(this.TextBox4.Text));
    }
    protected void Button6_Click(object sender, EventArgs e)
    {
        ShopCar<TestP2> car = ShopCar<TestP2>.LoadFromCookie(cookie + "2");
        car.Remove(this.TextBox5.Text);
    }
    protected void Button7_Click(object sender, EventArgs e)
    {
        ShopCar<TestP2> car = ShopCar<TestP2>.LoadFromCookie(cookie + "2");
        car.SetCount(this.TextBox5.Text, int.Parse(this.TextBox8.Text));
    }
}
